package pri.syl.xiaowu.websocket.netty.server.thread;

import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author YunLong
 * @Date 2021/7/18 19:27
 * @Description 握手抽象线程
 **/
@Getter
@Setter
public abstract class AbstractHttpServerHandshakeThread implements Runnable {
    private Channel channel;
    private FullHttpRequest request;
    private int maxFramePayloadLength;
    private int readTimeoutMilli;

    public AbstractHttpServerHandshakeThread(Channel channel, FullHttpRequest request, int maxFramePayloadLength, int readTimeoutMilli) {
        this.channel = channel;
        this.request = request;
        this.maxFramePayloadLength = maxFramePayloadLength;
        this.readTimeoutMilli = readTimeoutMilli;
    }

    /**
     * httpServerHandshake
     *
     * @param channel               channel
     * @param request               request
     * @param maxFramePayloadLength maxFramePayloadLength
     * @param readTimeoutMilli      readTimeoutMilli
     */
    protected abstract void httpServerHandshake(Channel channel, FullHttpRequest request, int maxFramePayloadLength, int readTimeoutMilli);

    @Override
    public void run() {
        httpServerHandshake(this.channel,
                this.request,
                this.maxFramePayloadLength,
                this.readTimeoutMilli);
    }
}
